package com.huidao.service.buyer;

import java.util.List;

import com.huidao.dao.buyer.ShoppingCartDao;
import com.huidao.dao.buyer.ShoppingCartDaoImpl;
import com.huidao.entity.Shoppingcart;
import com.huidao.entity.User;

public class ShoppingCartServiceImpl implements ShoppingCartService {
	ShoppingCartDao sd = new ShoppingCartDaoImpl();
	private int pagesize = 5;

	@Override
	public List<Shoppingcart> getShoppingcartList( int currentpage, String keyName,long id) {
		return sd.getShoppingcartList(currentpage, pagesize, keyName, id);
	}

	@Override
	public int getShoppingcartListTotalPage(String keyName, long id) {
		int totalPage = sd.getTotalPage(keyName, id);
		if(totalPage%pagesize==0){
			return totalPage/pagesize;
		}else{
			return totalPage/pagesize+1;
		}
	}
	
	@Override
	public String updateGoods_num(long shoppingcart_id, int goods_num) {
		if(sd.updateGoods_num(shoppingcart_id, goods_num)){
			return "";
		}else{
			return "修改成功";
		}
	}

	@Override
	public String addShoppingcart(Shoppingcart shoppingcart) {
		if(sd.addShoppingcart(shoppingcart)){
			return"";
		}
		return "添加成功";
	}
	public String delShoppingcart(long shoppingcart_id) {
		if(sd.delShoppingcart(shoppingcart_id)){
			return "";
		}else{
			return "删除失败";
		}
	}
	
	public String clearShoppingcart(User user){
		if(sd.clearShoppingcart(user)){
			return "";
		}else{
			return "清除失败";
		}
		
	}

}
